import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { SArenaCrossGroupBattle } from "../../../../../Message/Public/SArenaCrossGroupBattle";
import { PlayerUtil } from "../../common/util/PlayerUtil";
import { Cache } from "../../../cache/Cache";
import { CareerConfig } from "../../../resource/CareerConfig";
import { ObjTeamCreate } from "../../common/ObjTeamCreate";
import { GButton } from "../../../../../com/mui/controls/GButton";
//class ArenaCrossGroupMatchBattleCellRenderer
    
    export  class ArenaCrossGroupMatchBattleCellRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            this._btnOnePlayer = ObjCreate.createGButton("", 10, 14, 188, 28, this, "LinkButtonWhite");
            this._careerOne = ObjCreate.createTextField("", 10, 41, 100, 20, this);
            this._combatOne = ObjCreate.createTextField("", 110, 41, 100, 20, this);
            this._winOne = ObjCreate.createTextField("", 10, 61, 100, 20, this);
            this._loseOne = ObjCreate.createTextField("", 110, 61, 100, 20, this);
            this._bmpVs = ObjCreate.createBitmap(ImagesConst.ArenaVS, 210, 21, this);
            this._btnTwoPlayer = ObjCreate.createGButton("", 266, 14, 188, 20, this, "LinkButtonWhite");
            this._careerTwo = ObjCreate.createTextField("", 266, 41, 100, 20, this);
            this._combatTwo = ObjCreate.createTextField("", 366, 41, 100, 20, this);
            this._winTwo = ObjCreate.createTextField("", 266, 61, 100, 20, this);
            this._loseTwo = ObjCreate.createTextField("", 366, 61, 100, 20, this);
            this._btnLook = ObjCreate.createGButton(Language.getString(44274), 468, 39, 53, 22, this);
            this._tfEnd = ObjCreate.createTextField(Language.getString(44273), 468, 42, 53, 22, this, GlobalStyle.textFormat6);
            this._tfEnd.visible = false;
            this._tfNotStart = ObjCreate.createTextField(Language.getString(44378), 468, 42, 53, 22, this, GlobalStyle.textFormat6);
            this._tfNotStart.visible = false;
            ObjCreate.createBg(0, 94, 540, 2, this, "SplitLine");
            this._btnOnePlayer.addEventListener(flash.events.MouseEvent.CLICK, this.onClickOnePlayer);
            this._btnTwoPlayer.addEventListener(flash.events.MouseEvent.CLICK, this.onClickTwoPlayer);
            this._btnLook.addEventListener(flash.events.MouseEvent.CLICK, this.onClickLookBtn);
            return;
        }

        /* internal  */onClickLookBtn(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._arenaCrossGroupBattle) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossLookBattle, this._arenaCrossGroupBattle.arenaId));
            }
            return;
        }

        /* internal  */onClickOnePlayer(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._arenaCrossGroupBattle) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetArenaCrossPlayerInfo, this._arenaCrossGroupBattle.entityIdOne));
            }
            return;
        }

        /* internal  */onClickTwoPlayer(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._arenaCrossGroupBattle) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGetArenaCrossPlayerInfo, this._arenaCrossGroupBattle.entityIdTwo));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "sarenacrossgroupbattle") 
            {
                this._arenaCrossGroupBattle = arg1 as SArenaCrossGroupBattle;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            var loc1=false;
            var loc2=false;
            var loc3=false;
            var loc4=false;
            var loc5=null;
            var loc6=null;
            if (this._arenaCrossGroupBattle) 
            {
                this._btnOnePlayer.label = PlayerUtil.getProxyAndNameByEntityIdAndName(this._arenaCrossGroupBattle.entityIdOne, this._arenaCrossGroupBattle.nameOne);
                this._btnTwoPlayer.label = PlayerUtil.getProxyAndNameByEntityIdAndName(this._arenaCrossGroupBattle.entityIdTwo, this._arenaCrossGroupBattle.nameTwo);
                loc1 = this._arenaCrossGroupBattle.entityIdOne.typeEx == Cache.instance.role.entityInfo.entityId.typeEx && this._arenaCrossGroupBattle.entityIdOne.typeEx2 == Cache.instance.role.entityInfo.entityId.typeEx2;
                loc2 = this._arenaCrossGroupBattle.entityIdTwo.typeEx == Cache.instance.role.entityInfo.entityId.typeEx && this._arenaCrossGroupBattle.entityIdTwo.typeEx2 == Cache.instance.role.entityInfo.entityId.typeEx2;
                this._btnOnePlayer.styleName = loc1 ? "LinkButton" : "LinkButtonWhite";
                this._btnTwoPlayer.styleName = loc2 ? "LinkButton" : "LinkButtonWhite";
                this._btnOnePlayer.drawNow();
                this._btnTwoPlayer.drawNow();
                loc3 = this._arenaCrossGroupBattle.arenaId == 0;
                loc4 = this._arenaCrossGroupBattle.arenaId == -1;
                this._btnLook.visible = !loc3 && !loc4;
                this._tfEnd.visible = loc3;
                this._tfNotStart.visible = loc4;
                loc5 = this._arenaCrossGroupBattle.careerOne != 0 ? CareerConfig.instance.getInfoByCode(this._arenaCrossGroupBattle.careerOne).name : "0";
                loc6 = this._arenaCrossGroupBattle.careerTwo != 0 ? CareerConfig.instance.getInfoByCode(this._arenaCrossGroupBattle.careerTwo).name : "0";
                ObjTeamCreate.setTextFieldKeyValue(this._careerOne, Language.getString(44438), loc5);
                ObjTeamCreate.setTextFieldKeyValue(this._combatOne, Language.getString(44439), this._arenaCrossGroupBattle.warfareOne.toString());
                ObjTeamCreate.setTextFieldKeyValue(this._winOne, Language.getString(44484), this._arenaCrossGroupBattle.winNumOne.toString());
                ObjTeamCreate.setTextFieldKeyValue(this._loseOne, Language.getString(44485), this._arenaCrossGroupBattle.loseNumOne.toString());
                ObjTeamCreate.setTextFieldKeyValue(this._careerTwo, Language.getString(44438), loc6);
                ObjTeamCreate.setTextFieldKeyValue(this._combatTwo, Language.getString(44439), this._arenaCrossGroupBattle.warfareTwo.toString());
                ObjTeamCreate.setTextFieldKeyValue(this._winTwo, Language.getString(44484), this._arenaCrossGroupBattle.winNumTwo.toString());
                ObjTeamCreate.setTextFieldKeyValue(this._loseTwo, Language.getString(44485), this._arenaCrossGroupBattle.loseNumTwo.toString());
            }
            return;
        }

        /* internal */ /* var */_arenaCrossGroupBattle: SArenaCrossGroupBattle;

        /* internal */ /* var */_isResCompl: Boolean=false;

        /* internal */ /* var */_btnOnePlayer: GButton;

        /* internal */ /* var */_careerOne: Object /* flash.text.TextField */;

        /* internal */ /* var */_combatOne: Object /* flash.text.TextField */;

        /* internal */ /* var */_winOne: Object /* flash.text.TextField */;

        /* internal */ /* var */_loseOne: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpVs: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_btnTwoPlayer: GButton;

        /* internal */ /* var */_careerTwo: Object /* flash.text.TextField */;

        /* internal */ /* var */_combatTwo: Object /* flash.text.TextField */;

        /* internal */ /* var */_winTwo: Object /* flash.text.TextField */;

        /* internal */ /* var */_loseTwo: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfNotStart: Object /* flash.text.TextField */;

        /* internal */ /* var */_btnLook: GButton;

        /* internal */ /* var */_tfEnd: Object /* flash.text.TextField */;
    }
